#!/usr/bin/env python
# @Date    : 2022-04-25
# @Author  : Bright (brt2@qq.com)
# @Link    : https://gitee.com/brt2
# @Version : 0.1.0

import sys
sys.path.append("..")

import util
from src import webframe


# webframe.set_backend("flask")
# webframe.set_backend("fastapi")
webframe.set_backend("bottle")
# webframe.set_backend("sanic")
# webframe.set_backend("tornado")
app_name = util.get_app_name(__file__)
app = webframe.make_app(app_name)

@app.get("/")
def sayHello():
    return "Hello"

if False:
    # 服务发现
    import consul

    server_host = "127.0.0.1"
    _c = consul.Consul(host=server_host, port=8500)
    service = _c.agent.service
    serv_id = "QTools_by_FastAPI"
    service.register(
        name=app_name
        , address=server_host
        , port=1111
        , service_id=serv_id
    )

if __name__ == "__main__":
    webframe.app_run(app,
                    # "test/demo:app",  # when: fastapi/uvicorn
                    host="0.0.0.0",
                    debug=True,
                    reload=True,
                    port=1111)
